package com.wzcl.app.dao.model;


import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.wzcl.app.dao.model.common.Base;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Data
@Entity
@Table(name = "topic",
    indexes = {
        @Index(columnList = "type"),
        @Index(columnList = "hard")
    }
)
@ApiModel(value = "题目表")
@EntityListeners(AuditingEntityListener.class)
public class Topic implements Base {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @ApiModelProperty(value = "题目类型")
    private Integer type;

    @ApiModelProperty(value = "难度")
    private Integer hard;

    @ApiModelProperty(value = "题目材料")
    @Column(columnDefinition = "text")
    private String  master;

    @ApiModelProperty(value = "描述")
    private String description;

    @ApiModelProperty(value = "总分值")
    private Integer score;

    @CreatedDate
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @LastModifiedDate
    @ApiModelProperty(value = "修改时间")
    private Date updateTime;

    @JSONField(serialize = false)
    @OneToMany(cascade = CascadeType.REMOVE,mappedBy = "topic")
    @ApiModelProperty(value = "详情")
    private List<TopicInfo> topicInfoList;

    @JsonIgnore
    @OneToMany(mappedBy = "topic")
    private List<TopicAndKnowledgePoint> topicAndKnowledgePointList;
}
